import SearchCmp from "@/components/SearchCmp";
import TableCmp from "@/components/TableCmp";
import { getToken } from "@/utils/auth";
// const token =getToken()
// console.log('token: ', token);
export const MIX_Table = {
  data: function() {
    return {
      query: {
        pageInfo: {
          size: 20,
          page: 1,
          oderBy: "",
          sort: "",
          // token:getToken()
        }
      }, // 搜索按钮提交的表单
      searchBody: {}, // 搜索栏显示配置
      btnBody: {}, // 按钮显示配置
      tableData: [], // 表格数据源
      totalCount: 0, // 分页需要的数据总条数
      id: 180,
      tableHeight: "100%",
      loading: true
    };
  },
  components: {
    SearchCmp,
    TableCmp
  },
  created() {
    
  },
  methods: {
    /**
     *  搜索-按钮 响应事件
     */
    handleSearch() {
      this.loadData();
    },
    handleAdd(){
      this.addData();

    },

    handleCurrentChange(val) {
      this.query.pageInfo.page = val;
      this.loadData();
    },

    // 获取搜索表单内容
    getSearchBodyInfo() {
      setTimeout(() => {
        if (this.menuCfg[this.menuKey]) {
          this.searchBody = this.menuCfg[this.menuKey].queryPar;
          this.btnBody = this.menuCfg[this.menuKey].menuOper||[];
        }
      }, 20);
    }
  },
  // -------- 路由钩子函数
  /** 页面进入前 - 监听路由 */
  beforeRouteEnter: (to, from, next) => {
    next(vm => {
      vm.menuKey = to.meta.MenuId;
      if (vm.searchCfg) {
        vm.searchBody = vm.searchCfg.queryPar;
        vm.btnBody = vm.searchCfg.menuOper||[];
      }
    });
  }
};
